package com.friendfeed.api;


public class MediaThumbnail {
    private String url;
    private int width = -1;
    private int height = -1;

    public MediaThumbnail() {
    	super();
    }
    
    public MediaThumbnail(String url, int width, int height) {
        this.url = url;
        this.width = width;
        this.height = height;
    }

	public boolean isImgTag()
	{
		return FriendFeedUtils.isImgTag(this.url);
	}
	
	public String getImgTag()
	{
		if (isImgTag())
		{
			return this.url;
		}
		else
		{
			throw new IllegalStateException("not an img tag");
		}
	}

    public String getUrl() {
    	
		if (isImgTag())
		{
			return FriendFeedUtils.getUrlFromImgTag(url);  
		}
		else
		{
			return url;
		}
   	
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    
    
    public void setUrl(String url)
	{
		this.url = url;

	}

	public void setWidth(int width)
	{
		this.width = width;
	}

	public void setHeight(int height)
	{
		this.height = height;
	}

	public String toString() {
        return "MediaThumbnail{" +
                "height=" + height +
                ", width=" + width +
                ", url='" + url + '\'' +
                '}';
    }
}
